package custom;

import jdk.Person;

import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class CCTVMeiPo  implements  CCTVInvocationHandler{
    private Person target;

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("cctv自定义的媒婆：代理人是" + target.getName() + "(" + target.getSex() + ")");
        System.out.println("开始海选……");
        method.invoke(target,args);
        System.out.println("匹配上了");
        return null;
    }

    /**
     * 获取代理人个人资料
     *
     * @param target
     * @return
     */
    public Object getInstance(Person target) {
        this.target = target;
        Class clazz = target.getClass();
        System.out.println("原始对象："+clazz);
        return CCTVProxy.newProxyInstance(new CCTVClassLoader(), clazz.getInterfaces(), this);
    }

}
